package itsm.isperp.module.repository.configuration;

import itsm.isperp.framework.data.domain.DataRequest;
import itsm.isperp.framework.data.domain.DataResponse;
import itsm.isperp.framework.data.mybatis.dao.CUDMapper;
import itsm.isperp.module.dto.configuration.ConfCiRelationDTO;
import itsm.isperp.module.entity.configuration.ConfCiRelation;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * 配置关系数据访问
 * 
 * @author lizx
 * @date 2014-09-22 09:52
 */
@Repository
public interface ConfCiRelationMapper extends CUDMapper<ConfCiRelation> {

	List<ConfCiRelation> findByRelationTypeId(
			@Param("relationTypeId") String relationTypeId);

	List<ConfCiRelation> findByFromId(String fromId);

	List<ConfCiRelation> findByToId(String toId);

	ConfCiRelation findRelation(@Param("fromId") String fromId,
			@Param("fromCategoryId") String fromCategoryId,
			@Param("toCategoryId") String toCategoryId);

	ConfCiRelation findByFromIdAndToId(@Param("fromId") String fromId,
			@Param("toId") String toId);

	List<ConfCiRelation> findByFromIdOrToId(@Param("ciId") String ciId);

	List<ConfCiRelation> findByFromIdAndRelationTypeId(
			@Param("fromId") String fromId,
			@Param("relationTypeId") String relationTypeId);

	List<ConfCiRelation> findByToIdAndRelationTypeId(
			@Param("toId") String toId,
			@Param("relationTypeId") String relationTypeId);

	List<ConfCiRelation> findByFromIdAndUsePropertyType(
			@Param("fromId") String fromId,
			@Param("usePropertyType") String usePropertyType);

	List<ConfCiRelation> findByToIdAndUsePropertyType(
			@Param("toId") String toId,
			@Param("usePropertyType") String usePropertyType);

	/**
	 * 
	 * @param request
	 * @return
	 */
	DataResponse<ConfCiRelationDTO> findDtoByRequest(DataRequest request);

	void deleteByRelationTypeId(@Param("relationTypeId") String relationTypeId);

	void deleteByFromId(@Param("fromId") String fromId);
	
	DataResponse<Map<String,Object>> findRelateFromCiByRequest(DataRequest request);
	
	DataResponse<Map<String,Object>> findRelateToCiByRequest(DataRequest request);

}
